package icom.acm.util.spring;

import icom.acm.util.StaticData;

import java.io.File;


/**
 * 
 * @author 沈晨辉
 * spring 工厂制造springbeans
 */
public class SpringFactory {
	private static SpringFactory sf;
	
	private ISpring beanBeans;
	public String bean = StaticData.WEBINF_PATH + "\\bean.xml";//"workspace\\acmwb\\WebContent\\WEB-INF\\bean.xml";//"webapps\\OnLiveServerDemo\\WEB-INF\\bean.xml";//"WebContent\\WEB-INF\\bean.xml";//
	
	public static synchronized SpringFactory newInstance(){
		if (sf == null)
			sf = new SpringFactory();
		return sf;
	}
	
	public SpringFactory(){
File f = new File(bean);
System.out.println(f.getPath()+"\t" + f.getAbsolutePath() + "\t" + f.getParent());
System.out.println(f.exists());
	//	serviceBeans = new SpringBeans(service);
		beanBeans = new SpringBeans(bean);
	}

	public Object action(String xmlBeans, String bean){
		try {
			if (xmlBeans.equals(this.bean)){
				return beanBeans.action(bean);
			}
		} catch (Exception ex){
			ex.printStackTrace();
		}
		return null;
	}
}
